/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    transition: all 0.3s ease;
}

/* 背景主题 */
body.theme-wood {
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 50%, #CD853F 100%);
}

body.theme-marble {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

body.theme-space {
    background: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px),
        radial-gradient(white, rgba(255,255,255,.1) 2px, transparent 40px);
    background-size: 550px 550px, 350px 350px, 250px 250px;
    background-position: 0 0, 40px 60px, 130px 270px;
}

body.theme-nature {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 50%, #00b894 100%);
}

/* 游戏容器 */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* 游戏标题 */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    font-size: 3rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 15px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-secondary {
    background: linear-gradient(45deg, #f093fb, #f5576c);
    color: white;
}

.btn-info {
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* 游戏信息面板 */
.game-info {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.player-avatar {
    font-size: 3rem;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.player.active .player-avatar {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255,215,0,0.6);
}

.player-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.player-status {
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.2);
    color: #fff;
    transition: all 0.3s ease;
}

.player-status.active {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #000;
    animation: pulse 2s infinite;
}

.game-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.timer {
    font-size: 2rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.move-count {
    color: #fff;
    font-size: 1.1rem;
}

/* 棋盘容器 */
.game-board-container {
    position: relative;
    margin: 20px 0;
}

#gameBoard {
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    background: #DEB887;
    cursor: crosshair;
    transition: all 0.3s ease;
}

#gameBoard:hover {
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

.board-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    border-radius: 15px;
}

/* 游戏模式选择 */
.game-modes {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-btn {
    padding: 15px 25px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.mode-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.mode-btn.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    border-color: #FFD700;
    box-shadow: 0 0 20px rgba(255,215,0,0.4);
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #f5576c;
}

.modal-body {
    padding: 20px;
}

/* 设置面板 */
.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
}

.theme-selector {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-btn {
    padding: 10px 20px;
    border: 2px solid #ddd;
    border-radius: 15px;
    background: #f8f9fa;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.theme-btn.active {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

.sound-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sound-controls input[type="range"] {
    flex: 1;
    height: 5px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
}

.sound-controls input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    cursor: pointer;
}

/* 棋盘大小选择框样式 */
#boardSize {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 15px;
    background: #f8f9fa;
    color: #333;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
}

#boardSize:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

#boardSize:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: #fff;
}

#boardSize option {
    padding: 10px;
    background: #fff;
    color: #333;
    font-weight: 500;
}

/* 帮助内容 */
.help-content h4 {
    color: #333;
    margin-bottom: 10px;
    margin-top: 20px;
}

.help-content h4:first-child {
    margin-top: 0;
}

.help-content ul {
    padding-left: 20px;
    color: #555;
}

.help-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* 游戏结束面板 */
.game-result {
    text-align: center;
}

.winner-display {
    font-size: 4rem;
    margin-bottom: 20px;
}

.game-summary {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.6;
}

.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid #FFD700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
}

/* 动画定义 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .player-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .game-stats {
        order: -1;
    }
    
    #gameBoard {
        width: 100%;
        height: auto;
        max-width: 400px;
    }
    
    .game-modes {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        width: 200px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.5rem;
    }
    
    .player-avatar {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    
    .timer {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* 棋子放置动画 */
.piece-animation {
    animation: piecePlace 0.3s ease-out;
}

@keyframes piecePlace {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(90deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* 获胜线条动画 */
.winning-line {
    animation: winningLine 1s ease-in-out;
}

@keyframes winningLine {
    0% {
        stroke-dasharray: 0, 1000;
    }
    100% {
        stroke-dasharray: 1000, 0;
    }
}